<?php
/**
 * Created by PhpStorm.
 * User: Ysll <754060604@qq.com>
 * Date: 2017/10/10
 * Time: 11:19
 */

namespace Admin\Model;

class ContactUs extends Model
{
    protected $tableName = 'contact_us';

    /**
     * 获取第一条数据
     *
     * @return array|null
     */
    public static function findOne() {
        return self::getInstance()->find();
    }

    /**
     * 添加或更新
     *
     * @param array $data
     * @return int|boolean
     */
    public static function updateOrSave(array $data)
    {
        if (isset($data['id'])) {
            return self::getInstance()->where('id = ' . $data['id'])->save($data);
        } else {
            return self::getInstance()->add($data);
        }
    }
}